<?php
require_once("../../class2.php");
require_once("includes/require_all.php");
?>
<?php
$sterm= trim(strtolower($_GET['word']));
$sterm_short= mysql_real_escape_string($sterm[0].$sterm[1].$sterm[2]);
$sterm= mysql_real_escape_string($sterm);

$sresult= mysql_query("SELECT eng FROM dict_enbg WHERE eng = '$sterm' OR eng LIKE '$sterm_short%'");
while ($srow= mysql_fetch_array($sresult)) {
	$arr_results[$srow['eng']]= levenshtein($sterm,$srow['eng']);
}
$sreturn= array_keys($arr_results, min($arr_results));
$secho= mysql_fetch_array(mysql_query("SELECT bg FROM dict_enbg WHERE eng = '$sreturn[0]'"));
$secho= str_replace("\\n","<br>",$secho);

$secho= preg_replace("/([0-9А-я].*?)([A-z<])/", "<span id='sresult-cyrillic'>$1</span>$2", $secho);
?>
			<div id='sresult'>
				<div id='sresult-top'>
					<b><?php echo $sreturn[0]; ?></b>
					<button id='sresult-button' onclick="clearBox('enbgwordFOUND')">✖</button><br>
				</div><div id='sresult-cont'>
					<span><?php echo $secho['bg']; ?></span>
				</div>
			</div>